﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using DAO;
using System.Configuration;

namespace GUI
{
    static class Program
    {
        public static FrmManHinhChinh frm_manhinhchinh;
        public static string tenserver=ConfigurationManager.AppSettings["Server"].ToString();
        public static string tendata = ConfigurationManager.AppSettings["Database"].ToString();
        public static string username = ConfigurationManager.AppSettings["Username"].ToString();
        public static string password = ConfigurationManager.AppSettings["Password"].ToString();
        

        public static void HienThiChucNang(string tenquyen)
        {
            int csquyen = 0;
            if (tenquyen == null)
                csquyen = 0;
            if (tenquyen == "Quản Lý")
                csquyen = 1;
            if (tenquyen == "Thu Ngân")
                csquyen = 2;
            switch (csquyen)
            {
                case 0:
                    Program.frm_manhinhchinh.sub_mn_baocaoban.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaokhuvuc.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaomonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaothoigian.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_dangxuat.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_doimatkhau.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_inhoadon.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_laphoadon.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlban.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlkhuyenmai.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlloaimonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlmonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qltaikhoan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_tracuuban.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheogia.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheoloai.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_xulyban.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_capnhatthamso.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_hoadon.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_tracuumonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_ban.Visible = false;
                    break;
                case 1:
                    Program.frm_manhinhchinh.sub_mn_baocaoban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_baocaokhuvuc.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_baocaomonan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_baocaothoigian.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_dangxuat.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_doimatkhau.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_inhoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_laphoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlkhuyenmai.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlloaimonan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlmonan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qltaikhoan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuuban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheogia.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheoloai.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_xulyban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_capnhatthamso.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_hoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumonan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_ban.Visible = true;
                    break;
                case 2:
                    Program.frm_manhinhchinh.sub_mn_baocaoban.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaokhuvuc.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaomonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_baocaothoigian.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_dangxuat.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_doimatkhau.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_inhoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_laphoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_qlkhuyenmai.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlloaimonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qlmonan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_qltaikhoan.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_tracuuban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheogia.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumontheoloai.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_xulyban.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_capnhatthamso.Visible = false;
                    Program.frm_manhinhchinh.sub_mn_hoadon.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_tracuumonan.Visible = true;
                    Program.frm_manhinhchinh.sub_mn_ban.Visible = true;
                    break;
            }
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            frm_manhinhchinh = new FrmManHinhChinh();
            if (DataProvider.ConnectToDatabase(tenserver,tendata,username,password)==true)
            {
                DataProvider.sqlconn.Close();
                Application.Run(frm_manhinhchinh);
            }
            else
            {
                Application.Run(new FrmCauHinhKetNoi());
            }
        }
    }
}
